/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ep.persistence.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Spyros
 */
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
@Entity
@Table(name = "t004_insurance", catalog = "epresc", schema = "")
@NamedQueries({
    @NamedQuery(name = "T004Insurance.findAll", query = "SELECT t FROM T004Insurance t"),
    @NamedQuery(name = "T004Insurance.findById", query = "SELECT t FROM T004Insurance t WHERE t.id = :id"),
    @NamedQuery(name = "T004Insurance.findByCode", query = "SELECT t FROM T004Insurance t WHERE t.code = :code"),
    @NamedQuery(name = "T004Insurance.findByName", query = "SELECT t FROM T004Insurance t WHERE t.name = :name")})
public class T004Insurance implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Column(name = "code")
    private String code;
    @Basic(optional = false)
    @Column(name = "name")
    private String name;
//    @OneToMany(cascade = CascadeType.ALL, mappedBy = "t004Insurance")
//    private Collection<T005Patient> t005PatientCollection;
    @ManyToMany
    @JoinTable(name = "t002_t004",
    joinColumns =
    @JoinColumn(name = "t004_insurance_id"),
    inverseJoinColumns =
    @JoinColumn(name = "t002_doctor_id"))
    private Collection<T002Doctor> t002Doctors;

    public T004Insurance() {
    }

    public T004Insurance(Integer id) {
        this.id = id;
    }

    public T004Insurance(Integer id, String name) {
        this.id = id;
        this.name = name;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

//    public Collection<T005Patient> getT005PatientCollection() {
//        return t005PatientCollection;
//    }
//
//    public void setT005PatientCollection(Collection<T005Patient> t005PatientCollection) {
//        this.t005PatientCollection = t005PatientCollection;
//    }

    @XmlTransient
    public Collection<T002Doctor> getT002Doctors() {
        return t002Doctors;
    }

    public void setT002Doctors(Collection<T002Doctor> t002Doctors) {
        this.t002Doctors = t002Doctors;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof T004Insurance)) {
            return false;
        }
        T004Insurance other = (T004Insurance) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return getName();
    }

}
